﻿@using ZBJF.Warranty.Common.Enums
@using ZBJF.Warranty.WebProvider
@{
    ViewBag.Title = "服务商产品管理";
}
<div class="breadcrumbs" id="breadcrumbs">
    <ul class="nav nav-tabs">
        <li class="active"><a href="/ServiceProviderProduct/ServiceProviderProductIndex">服务商产品列表</a></li>
        <li class="Add-R"><a href="/ServiceProviderProduct/ServiceProviderProductEdit/0">添加服务商产品</a></li>
    </ul>
</div>
<form id="searchForm" class="breadcrumb form-search">
    <div>
        <label>服务商名称：</label>
        @Html.DropDownList("ServiceProviderId", ConvertToSelector.Instance.ServiceProviderConvertToSelectList(), new { validate = "{required:true,messages:{required:'请选择所属服务商'}}" })
        <label>服务商产品名称：</label>
        @Html.TextBox("ThridProductName", "", new { placeholder = "请输入服务商产品名称" })
        <label>服务项目名称：</label>
        @Html.TextBox("ProjectName", "", new { placeholder = "请输入服务项目名称" })
        <input id="btnReset" class="btn Search-R form-reset" type="button" value="重置">
        <input id="btnSubmit" class="btn btn-primary Search-R" type="button" value="查询" onclick="search();">
    </div>
</form>
<table id="ServiceProviderProductTable" class="table table-striped table-bordered table-hover">
    <thead>
        <tr>
            <th width="50">序号</th>
            <th>服务商名称</th>
            <th>服务商产品名称</th>
            <th>单价</th>
            <th>服务项目名称</th>
            <th>服务项目单价</th>
            <th>是否启用</th>
            <th>最后修改人</th>
            <th>最后修改时间</th>
            <th width="150">
                操作
            </th>
        </tr>
    </thead>
</table>
@section scripts{
    @Scripts.Render("~/bundles/chosen")
    @Styles.Render("~/Content/chosen")
    @Scripts.Render("~/bundles/datatable")
    @Styles.Render("~/Content/datatable")
    <script src="~/Scripts/moment.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#RoleListID").chosen();
            var objTable = $("#ServiceProviderProductTable").dataTable({
                fnDrawCallback: function () {
                    ControlPermissionOperate();
                },
                "sAjaxSource": "/ServiceProviderProduct/ServiceProviderProductList",
                "aaSorting": [[7, "desc"]],
                aoColumns: [
                    {
                        "mData": null,
                        "bSortable": false,
                        "fnRender": function (nRow) {
                            return nRow.iDataRow + 1;
                        }
                    },
                    { "mData": "ServiceProviderName", "bSortable": false },
                    { "mData": "ThirdProductName", "bSortable": false },
                    { "mData": "ThirdProductPrice" },
                    { "mData": "ProjectName", "bSortable": false },
                    { "mData": "Price" },
                    {
                        "mData": null,
                        fnRender: function (nRow) {
                            return nRow.aData.IsAvailable ? bootStrapOkIncon : bootStrapRemoveIncon;
                        }
                    },
                    { "mData": "LastModifyBy", "bSortable": false },
                    {
                        "mData": null,
                        fnRender: function (nRow) {
                            return moment(nRow.aData.LastModifyTime).format('YYYY-MM-DD HH:mm:ss');
                        }
                    },
                    {
                        "mData": null,
                        "bSortable": false,
                        fnRender: function (nRow) {
                            var html = "<a class='Edit-R' href='/ServiceProviderProduct/ServiceProviderProductEdit/" + nRow.aData.ID + "' title='edit'><i class='icon-edit'></i></a>";
                            html += "<a class=\"green Edit-R\" href=\"javascript:UpdateStatus('" + nRow.aData.ID + "'," + !nRow.aData.IsAvailable + ",'/ServiceProviderProduct/UpdateStatus','ServiceProviderProductTable')\" title=\"" + (nRow.aData.IsAvailable ? "禁用" : "启用") + "\">" + (nRow.aData.IsAvailable ? bootStrapRemoveIncon : bootStrapOkIncon) + "</a>";
                            return html;
                        }
                    }
                ]
            });
        });

        function search() {
            /*给查询对象赋值*/
            queryParamList.ServiceProviderId = String($("#ServiceProviderId").val());
            queryParamList.ThridProductName = String($("#ThridProductName").val());
            queryParamList.ProjectName = String($("#ProjectName").val());
            $("#ServiceProviderProductTable").dataTable().fnDraw();
        }

    </script>
}
